package com.sanpu.kxe.business.main.view;

import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.main.adapter.AdviceListAdapter;
import com.sanpu.kxe.business.main.bean.AdviceOutput;
import com.sanpu.kxe.business.main.contract.MainConfig;
import com.sanpu.kxe.utils.VerifyUtil;

import butterknife.Bind;

/**
 * Description：了难提交详情
 * Created by 薛勇军 on 2019/3/12.
 */

public class AdviceDetailActivity extends BaseTitleActivity {

    @Bind(R.id.adviceTypeTv)
    TextView vAdviceTypeTv;
    @Bind(R.id.contactTv)
    TextView vContactTv;
    @Bind(R.id.phoneTv)
    TextView vPhoneTv;
    @Bind(R.id.explainTv)
    TextView vExplainTv;
    @Bind(R.id.statuTv)
    TextView vStatuTv;
    @Bind(R.id.failTv)
    TextView vFailTv;
    @Bind(R.id.failLayout)
    LinearLayout vFailLayout;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_advice_detail;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("了难明细");
    }

    @Override
    protected void initData() {
        super.initData();
        AdviceOutput adviceOutput = (AdviceOutput) getIntent().getSerializableExtra(MainConfig.INTENT_ADVICE_ENTITY);
        if (adviceOutput != null) {
            vAdviceTypeTv.setText(AdviceListAdapter.getTitleByType(adviceOutput.getTaskType()));
            vContactTv.setText(VerifyUtil.secretCrpName(adviceOutput.getContactName()));
            vPhoneTv.setText(VerifyUtil.secretPhoneNumber(adviceOutput.getContactNumber()));
            if (!TextUtils.isEmpty(adviceOutput.getTaskDescription())) {
                vExplainTv.setText(adviceOutput.getTaskDescription());
            }
            vStatuTv.setText(AdviceListAdapter.getTitleByStatus(adviceOutput.getTaskStatus()));
            if (TextUtils.equals("CLOSED", adviceOutput.getTaskStatus())) {
                vFailLayout.setVisibility(View.VISIBLE);
                if (!TextUtils.isEmpty(adviceOutput.getDefeatedCause())) {
                    vFailTv.setText(adviceOutput.getDefeatedCause());
                }
            }
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }
}
